
package org.openhds.domain.model;

import java.io.Serializable;
import java.util.Calendar;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.openhds.domain.annotations.Description;
import org.openhds.domain.constraint.CheckEntityNotVoided;
import org.openhds.domain.constraint.CheckIndividualGenderFemale;
import org.openhds.domain.constraint.CheckIndividualNotUnknown;
import org.openhds.domain.constraint.Searchable;


/**
 * Generated by JCodeModel
 * 
 */
@Description(description = "A Pregnancy Observation is used to monitor a pregnancy. It contains information about the mother who is pregnant, the date the pregnancy started, as well as the expected delivery date.")
@Entity
@Table(name = "pregnancyobservation")
@XmlRootElement(name = "pregnancyobservation")
public class PregnancyObservation
    extends AuditableCollectedEntity
    implements Serializable
{

    public final static long serialVersionUID = -4737117368371754337L;
    @CheckIndividualNotUnknown
    @Searchable
    @CheckIndividualGenderFemale(allowNull = true, message = "The mother specified is not female gender")
    @CheckEntityNotVoided(allowNull = true, message = "The mother has been voided")
    @ManyToOne(cascade = {
        CascadeType.MERGE,
        CascadeType.PERSIST
    }, targetEntity = org.openhds.domain.model.Individual.class)
    @Description(description = "The mother of the pregnancy observation, identified by the external id.")
    private Individual mother;
    @NotNull
    @Temporal(TemporalType.DATE)
    @Description(description = "Expected delivery date.")
    private Calendar expectedDeliveryDate;
    @Past
    @NotNull
    @Temporal(TemporalType.DATE)
    @Description(description = "Recorded date of the pregnancy observation.")
    private Calendar recordedDate;
    @Searchable
    @NotNull
    @ManyToOne
    @Description(description = "The visit this pregnancy observation was registered during.")
    private Visit visit;

    public Individual getMother() {
        return mother;
    }

    public void setMother(Individual mom) {
        mother = mom;
    }

    @XmlJavaTypeAdapter(org.openhds.domain.util.CalendarAdapter.class)
    public Calendar getExpectedDeliveryDate() {
        return expectedDeliveryDate;
    }

    public void setExpectedDeliveryDate(Calendar date) {
        expectedDeliveryDate = date;
    }

    @XmlJavaTypeAdapter(org.openhds.domain.util.CalendarAdapter.class)
    public Calendar getRecordedDate() {
        return recordedDate;
    }

    public void setRecordedDate(Calendar date) {
        recordedDate = date;
    }

    public Visit getVisit() {
        return visit;
    }

    public void setVisit(Visit vis) {
        visit = vis;
    }

}
